<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建英雄对象</title>
    <script>
        function Person(name, type, blood, attack) {
            this.name = name;
            this.type = type;
            this.blood = blood;
            this.attack = attack;
            this.game = function () {
                console.log(this.name + 'is' + this.type +
                    'and blood have' + this.blood + 'and can' + this.attack);
            }
        }
        var houyi = new Person('后羿', '射手', 3569, '远程');
        houyi.game();

        var lianpuo = new Person('廉颇', '战士', 4890, '近战');
        lianpuo.game();
    </script>
</head>

<body>

</body>

</html>